package ch.epfl.lara.matcheck.util.printer;

object MatcheckUsagePrinter extends Formatter {
  private val RIGHT_COL: Int = 25 
    
  private val buf = new StringBuffer
  
  append(NL)
  appendNL("[Usage: matcheck <options | config file | source file>]")
  appendNL("where possible standard options include:")
  appendOptions
  append(NL)
  
  private def append(msg: String) {
    buf.append(mkIndent + msg)
  }
  
  private def appendNL(msg: String) {
    buf.append(mkIndent + msg + NL)
  }
  
  def appendOptions {
    inc
    buf.append(mkIndent)
    for((option,description)<-Options.option2description.elements) {
      val name = Options.getName(option)
      val length = name.length()
      buf.append(name)
      assert(RIGHT_COL - length > 0)
      buf.append(mkSpaces(RIGHT_COL - length))
      buf.append(description)
      buf.append(NL)
    }
    dec
  }
  
  def apply: Unit = Report.print(buf.toString)
}
